package com.ruyuan.commodity.client;

import com.ruyuan.commodity.api.GoodsQuantityClient;
import com.ruyuan.commodity.common.mamager.GoodsQuantityManager;
import com.ruyuan.commodity.domain.UpdateGoodsQuantityRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品库存操作的对外接口
 */
@RestController
public class GoodsQuantityClientDefaultImpl implements GoodsQuantityClient {

    /**
     * 存储操作的业务类
     */
    @Autowired
    private GoodsQuantityManager goodsQuantityManager;

    /**
     * 库存更新接口
     * @param request 库存更新请求对象
     * @return 如果扣减成功返回true，否则返false
     */
    @Override
    public Boolean updateSkuQuantity(UpdateGoodsQuantityRequest request) {
        return goodsQuantityManager.updateSkuQuantity(request.getGoodsQuantityList());
    }

}
